package practice.chapter03.stream;

import practice.chapter03.stream.interfaces.FileMethods;

import java.io.*;

public class TestFile implements FileMethods {
    public static void main(String[] args) throws IOException {
        TestFile test = new TestFile();
        test.writeFile();
        test.readFile();

    }

    @Override
    public void readFile() throws IOException {
        InputStream is = new FileInputStream("F:/0temp/hello.txt");
        int size = is.read();
        char c = ' ';
        for (int i = 0; i < size; i++) {
            c = (char) is.read();
            System.out.print(c);
        }
        is.close();
    }

    @Override
    public void writeFile() throws IOException {
        OutputStream os = new FileOutputStream("F:/0temp/hello.txt");
        String str = "test write file";
        os.write(str.getBytes());
        os.close();
        System.out.println("写入完成");
    }
}
